﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Qiang.Styles
{
    public class SimplePointStyle : PointStyle,ISimplePointStyle
    {

        #region 初始化


        public SimplePointStyle()
        {
            _color = Color.FromArgb(255, Random.Next(0, 255), Random.Next(0, 255), Random.Next(0, 255));
            _pointShape = Styles.PointShape.Ellipse;
        }


        #endregion


        #region 属性


        Color _color;

        /// <summary>
        /// 颜色。
        /// </summary>
        public Color Color
        {
            get { return _color; }
            set { _color = value; }
        }


        PointShape _pointShape;

        /// <summary>
        /// 点形状。
        /// </summary>
        public PointShape PointShape
        {
            get { return _pointShape; }
            set { _pointShape = value; }
        }

        /// <summary>
        /// 样式类型。
        /// </summary>
        public override PointStyleType StyleType
        {
            get { return PointStyleType.Simple; }
        }

        /// <summary>
        /// 透明度。
        /// </summary>
        public override float Opacity
        {
            get
            {
                return _color.A / 255f;
            }
            set
            {
                float val = value;
                if (val > 1) val = 1f;
                if (val < 0) val = 0f;
                _color = Color.FromArgb((int)val * 255, _color);
            }
        }


        #endregion


        #region 方法

        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="position"></param>
        public override void Draw(Graphics g, Point position)
        {
            Brush brush = ToBrush();

            switch (_pointShape)
            {
                case PointShape.Diamond:
                   
                    break;
                case PointShape.Ellipse:
                    g.FillEllipse(brush, position.X - Size.Width / 2, position.Y - Size.Height / 2, Size.Width, Size.Height);
                    break;
                case PointShape.Rectangle:
                    g.FillRectangle(brush, position.X - Size.Width / 2, position.Y - Size.Height / 2, Size.Width, Size.Height);
                    break;
                case PointShape.Star:

                    break;
                case PointShape.Triangle:

                    break;
                default:

                    break;
            }

            brush.Dispose();
        }

        public override Brush ToBrush()
        {
            Brush brush = new SolidBrush(_color);
            return brush;
        }

        #endregion


    }
}
